package com.lxk.finance.domain.bo;

import cn.hutool.core.collection.CollUtil;
import com.lxk.finance.domain.AccUserAccountRecord;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.mybatis.core.domain.BaseEntity;

import java.math.BigDecimal;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 账户流水业务对象 acc_user_account_record
 *
 * @author LXK-RY5
 * @date 2024-07-08
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = AccUserAccountRecord.class, reverseConvertGenerate = false)
public class AccUserAccountRecordBo extends BaseEntity {

    /**
     *
     */
    @NotNull(message = "不能为空", groups = { EditGroup.class })
    private Long id;

    /**
     * 用户ID
     */
    @NotNull(message = "用户ID不能为空", groups = { AddGroup.class, EditGroup.class })
    private Long userId;

    /**
     * 账户类型
     */
    @NotNull(message = "账户类型不能为空", groups = { AddGroup.class, EditGroup.class })
    private Integer accountType;

    /**
     * 流水金额
     */
    @NotNull(message = "流水金额不能为空", groups = { AddGroup.class, EditGroup.class })
    private BigDecimal amount;

    /**
     * 账号ID
     */
    @NotNull(message = "账号ID不能为空", groups = { AddGroup.class, EditGroup.class })
    private Long accountId;

    /**
     * 流水号
     */
    @NotBlank(message = "流水号不能为空", groups = { AddGroup.class, EditGroup.class })
    private String accountSn;

    /**
     * 订单编号
     */
    @NotBlank(message = "订单编号不能为空", groups = { AddGroup.class, EditGroup.class })
    private String orderSn;

    /**
     * 额外信息
     */
    @NotBlank(message = "额外信息不能为空", groups = { AddGroup.class, EditGroup.class })
    private String extraInfo;

    /**
     * 剩余金额
     */
    @NotNull(message = "剩余金额不能为空", groups = { AddGroup.class, EditGroup.class })
    private BigDecimal leftAmount;

    /**
     * 备注
     */
    private String remark;

    /**
     * 收支状态,1=收入 0=支出 income_status
     */
    @NotNull(message = "收支状态,1=收入 0=支出 income_status不能为空", groups = { AddGroup.class, EditGroup.class })
    private Integer incomeStatus;

    /**
     * 用户类型
     */
    @NotBlank(message = "用户类型不能为空", groups = { AddGroup.class, EditGroup.class })
    private String userType;

    /**
     * 是否提现(0不是 1是)withdraw_status
     */
    @NotNull(message = "是否提现(0不是 1是)withdraw_status不能为空", groups = { AddGroup.class, EditGroup.class })
    private Integer withdrawStatus;


    /**
     * 1=收入 0=支出
     */
    @Getter
    @AllArgsConstructor
    public enum IncomeStatus {
        OUT(0, "支出"),
        IN(1, "收入"),

        ;
        private final Integer code;

        private final String name;
        private static final Map<Integer, IncomeStatus> map = CollUtil.toList(IncomeStatus.values()).stream().collect(Collectors.toMap(IncomeStatus::getCode, v->v));
        public static Boolean containCode(Integer code ) {
            return map.containsKey(code);
        }
        public static IncomeStatus getByCode(Integer code) {
            return map.get(code);
        }
    }


}
